<template>
  <el-card shadow="never" class="aui-card--fill">
    <div class="mod-course__courseinitial}">
      <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
        <el-form-item>
          <el-input v-model="dataForm.courseName" placeholder="课程名称" clearable></el-input>
        </el-form-item>
        <el-form-item>
          <el-input v-model="dataForm.courseTeacher" placeholder="任课教师" clearable></el-input>
        </el-form-item>
        <el-form-item>
          <el-button @click="getDataList()">{{ $t('query') }}</el-button>
        </el-form-item>
        <el-form-item>
          <el-button @click="importHandle()" type="success" >{{ $t('import') }}</el-button>
        </el-form-item>
        <el-form-item>
          <el-button type="info" @click="exportHandle()">{{ $t('export') }}</el-button>
        </el-form-item>
        <el-form-item>
          <el-button v-if="$hasPermission('course:courseinitial:save')" type="primary" @click="addOrUpdateHandle()">{{ $t('add') }}</el-button>
        </el-form-item>
        <el-form-item>
          <el-button v-if="$hasPermission('course:courseinitial:delete')" type="danger" @click="deleteHandle()">{{ $t('deleteBatch') }}</el-button>
        </el-form-item>
      </el-form>
      <el-table v-loading="dataListLoading" :data="dataList" border @selection-change="dataListSelectionChangeHandle" style="width: 100%;">
        <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
        <el-table-column prop="id" label="序号" header-align="center" align="center"></el-table-column>
        <el-table-column prop="courseId" label="开课编号" header-align="center" align="center"></el-table-column>
        <el-table-column prop="planType" label="计划类型" header-align="center" align="center"></el-table-column>
        <el-table-column prop="courseCollege" label="开课学院" header-align="center" align="center"></el-table-column>
        <el-table-column prop="courseType" label="课程类别" header-align="center" align="center"></el-table-column>
        <el-table-column prop="courseClass" label="课程分类" header-align="center" align="center"></el-table-column>
        <el-table-column prop="courseName" label="课程名称" header-align="center" align="center"></el-table-column>
        <el-table-column prop="className" label="教学班名称" header-align="center" align="center"></el-table-column>
        <el-table-column prop="timeSum" label="总学时" header-align="center" align="center"></el-table-column>
        <el-table-column prop="timeTheory" label="理论学时" header-align="center" align="center"></el-table-column>
        <el-table-column prop="praticeTime" label="实践学时" header-align="center" align="center"></el-table-column>
        <el-table-column prop="credit" label="学分" header-align="center" align="center"></el-table-column>
        <el-table-column prop="chooseNum" label="选课人数" header-align="center" align="center"></el-table-column>
        <el-table-column prop="courseCampus" label="开课校区" header-align="center" align="center"></el-table-column>
        <el-table-column prop="courseTeacher" label="任课教师" header-align="center" align="center"></el-table-column>
        <el-table-column prop="teacherId" label="任课教师编号" header-align="center" align="center"></el-table-column>
        <el-table-column prop="comment" label="备注" header-align="center" align="center"></el-table-column>
        <el-table-column prop="courseInformation" label="课表信息" header-align="center" align="center"></el-table-column>
        <el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" width="150">
          <template slot-scope="scope">
            <el-button v-if="$hasPermission('course:courseinitial:update')" type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">{{ $t('update') }}</el-button>
            <el-button v-if="$hasPermission('course:courseinitial:delete')" type="text" size="small" @click="deleteHandle(scope.row.id)">{{ $t('delete') }}</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        :current-page="page"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="limit"
        :total="total"
        layout="total, sizes, prev, pager, next, jumper"
        @size-change="pageSizeChangeHandle"
        @current-change="pageCurrentChangeHandle">
      </el-pagination>
      <!-- 弹窗, 新增 / 修改 -->
      <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
      <!-- 弹窗, 上传文件 -->
      <Import v-if="importVisible" ref="import" @refreshDataList="getDataList"></Import>
    </div>
  </el-card>
</template>

<script>
import mixinViewModule from '@/mixins/view-module'
import AddOrUpdate from './courseinitial-add-or-update'
import Import from './courseinitial-import'
export default {
  mixins: [mixinViewModule],
  data () {
    return {
      mixinViewModuleOptions: {
        getDataListURL: '/course/courseinitial/page',
        getDataListIsPage: true,
        exportURL: '/course/courseinitial/export',
        deleteURL: '/course/courseinitial',
        deleteIsBatch: true
      },
      dataForm: {
        id: ''
      },
      importVisible: false
    }
  },
  components: {
    AddOrUpdate,
    Import
  },
  methods: {
    // 导入文件
    importHandle () {
      this.importVisible = true
      this.$nextTick(() => {
        this.$refs.import.init()
      })
    }
  }
}
</script>
